package com.hr.dao;

import com.hr.model.Archive;
import com.hr.model.Company;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CompanyDAO
{
    @Results(id="company",value = {
            @Result(id = true, property = "id", column = "c_id"),
            @Result(property = "name", column = "c_name"),
            @Result(property = "code", column = "c_code"),
            @Result(property = "industry", column = "c_industry"),
            @Result(property = "date", column = "c_date"),
            @Result(property = "size", column = "c_size"),
            @Result(property = "grade", column = "c_grade"),
            @Result(property = "tel", column = "c_tel"),
            @Result(property = "policy", column = "c_policy"),
            @Result(property = "area", column = "c_area"),
            @Result(property = "degree", column = "c_degree"),
            @Result(property = "school", column = "c_school"),
            @Result(property = "major", column = "c_major"),
            // list
            @Result(property = "departments", column = "c_id", many = @Many(select = "com.hr.dao.DepartmentDAO.getDepartmentsByCId")),

    })
    @Select("select * from company where c_id=#{cid}")
    Company getCompanyByCId(@Param("cid")int cid);

    @ResultMap("company")
    @Select("select * from company")
    List<Company> getAllCompanys();

}
